package org.bozo.im.service.core.roster;

import org.bozo.im.common.types.Protocol;

public class ContactId {
	private Protocol mProtocol;
	private String mHandle;
	
	private ContactId() {}
	
	public static ContactId build(Protocol pProtocol, String pHandle) {
		ContactId lRes = new ContactId();
		lRes.mHandle = pHandle;
		lRes.mProtocol = pProtocol;
		return lRes;
	}
	
	public Protocol getProtocol() {
		return mProtocol;
	}

	public String getHandle() {
		return mHandle;
	}

	@Override
	public boolean equals(Object pObj) {
		return (pObj instanceof ContactId
				&& ((ContactId)pObj).mProtocol == mProtocol
				&& ((ContactId)pObj).mHandle.equals(mHandle));
	}
	
	@Override
	public int hashCode() {
		return mProtocol.hashCode() & mHandle.hashCode();
	}
}
